package com.sd.sdk.core.utils;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 *
 * @author xy
 */
public class ApiMD5Util {

    public static String digest(String src) {
        return digest(src.getBytes(StandardCharsets.UTF_8));
    }

    public static String digest(byte[] src) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] digest = md.digest(src);
            return ApiHexUtil.encode(digest);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return null;
    }

}
